/**
 * 
 */
package com.p2p.front.jms.producer;

import java.io.Serializable;

import javax.annotation.Resource;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;

import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Service;

/**
 * @author ruiqi
 *
 */

public class ProducerService {

	@Resource
	private JmsTemplate jmsTemplate;
	
	public void sendMessage(Destination destination, final Serializable object) {  
	      
        jmsTemplate.send(destination, new MessageCreator() {  
            public Message createMessage(Session session) throws JMSException {  
                return session.createObjectMessage(object);
            }  
        });  
    }
	
}
